package com.dsp.cart.rest;

import com.dsp.cart.client.InventoryClient;
import com.dsp.cart.dto.CartDTO;
import com.dsp.cart.service.CartService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class CartController {

    @Resource
    InventoryClient inventoryClient;
    @Resource
    private CartService cartService;

    @GetMapping("/all")
    public Object list() {
        System.out.println(inventoryClient.test());
        return cartService.findAll();
    }

    @GetMapping("/submitOrder")
    public Object submitOrder(@RequestBody CartDTO cartDTO) {
        return cartService.submitOrder(cartDTO);
    }

    @GetMapping("/submitOrderException")
    public Object submitOrderException(@RequestBody CartDTO cartDTO) {
        return cartService.submitOrderException(cartDTO);
    }

}